<template>
   <div>
    <MyHeader title="购物车" color='#003333' bgc='#00a0ff'></MyHeader>
    <div class="main">
      <MyGoods v-for="item in list" :key='item.id' :good='item'></MyGoods>
    </div>
    <MyFooter :list='list'></MyFooter>
  </div>
</template>

<script>
import MyHeader from './components/MyHeader'
import MyGoods from './components/MyGoods'
import MyFooter from './components/MyFooter'
export default {
  components: {
    MyHeader,
    MyGoods,
    MyFooter
  },
  data () {
    return {
      list:[], // 商品所有数据
    }
  },
  created () {
    // 利用axios, 调用接口, 把数据请求回来
    this.$axios({
       url: "/api/cart"
    }).then(res => {
      // console.log(res)
      this.list = res.data.list
    }).catch(err => {
      console.log(err)
    })
  }
}
</script>

<style>
  .main{
    padding-top: 45px;
    padding-bottom: 50px;
  }
</style>